package com.wjv.example.spbt.mybatis.service;

import com.wjv.example.spbt.mybatis.entity.DictGenreEntity;
import com.wjv.example.spbt.mybatis.entity.FilmmakerEntity;
import com.wjv.example.spbt.mybatis.mapper.DictGenreMapper;
import com.wjv.example.spbt.mybatis.mapper.FilmmakerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>Title: FilmmakerServiceImpl</p>
 *
 * @author wjv
 * @date 2021/4/9 10:46
 * @description
 */
@Service
public class FilmmakerServiceImpl {

    @Autowired
    private FilmmakerMapper filmmakerMapper;
    @Autowired
    private DictGenreMapper dictGenreMapper;

    public void getFilmmakerById(int id) {
        FilmmakerEntity entity = filmmakerMapper.queryById(id);
        System.out.println(entity.toString());

        FilmmakerEntity entity2 = filmmakerMapper.queryById2(id);
        System.out.println(entity2.toString());
    }

    @Transactional(rollbackFor = Exception.class)
    public void saveDictGenre() {
        DictGenreEntity entity = new DictGenreEntity();
        entity.setGenreName("喜剧片" + System.currentTimeMillis());

        Integer i = dictGenreMapper.save(entity);
        System.out.println(i);
        System.out.println(entity.toString());

        int a = 10 / 0;
    }
}
